const request = require('request');
var httpAgent = require('socks5-http-client/lib/Agent');
var httpsAgent = require('socks5-https-client/lib/Agent');

var url = 'https://www.baidu.com';
var Agent = /^https/.test(url) ? httpsAgent : httpAgent;
request({
    url: url,
    strictSSL: false,
    agentClass: Agent
}, function (err, res) {
    console.log(err || res);
});